﻿namespace QMVnSoft.DAL
{
    using System;
    using System.Data;
    using System.Data.SqlClient;

    public class PriceCalculateDataAccess
    {
        public void Calculate0(string ps_Subsidiary, object pd_Ngay_Ct1, object pd_Ngay_Ct2, object ps_Ma_Kho, object ps_Ma_Vt)
        {
            SqlParameter[] values = new SqlParameter[] { new SqlParameter("p_Ma_Dvcs", ps_Subsidiary), new SqlParameter("p_Ngay_Ct1", pd_Ngay_Ct1), new SqlParameter("p_Ngay_Ct2", pd_Ngay_Ct2), new SqlParameter("p_Ma_Kho", ps_Ma_Kho), new SqlParameter("p_Ma_Vt", ps_Ma_Vt) };
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "Tinh_Gia_TBDD";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                command.Parameters.AddRange(values);
                command.ExecuteNonQuery();
                AppDataAccess.CloseConnection(eZConnection);
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
        }

        public void Calculate1(string ps_Subsidiary, object pd_Ngay_Ct1, object pd_Ngay_Ct2, object ps_Ma_Kho, object ps_Ma_Vt)
        {
            SqlParameter[] values = new SqlParameter[] { new SqlParameter("p_Ma_Dvcs", ps_Subsidiary), new SqlParameter("p_Ngay_Ct1", pd_Ngay_Ct1), new SqlParameter("p_Ngay_Ct2", pd_Ngay_Ct2), new SqlParameter("p_Ma_Kho", ps_Ma_Kho), new SqlParameter("p_Ma_Vt", ps_Ma_Vt) };
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "Tinh_Gia_TBTH";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                command.Parameters.AddRange(values);
                command.ExecuteNonQuery();
                AppDataAccess.CloseConnection(eZConnection);
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
        }
        public void Calculate2(string ps_Subsidiary, object pd_Ngay_Ct1, object pd_Ngay_Ct2, object ps_Ma_Kho, object ps_Ma_Vt)
        {
            SqlParameter[] values = new SqlParameter[] { new SqlParameter("p_Ma_Dvcs", ps_Subsidiary), new SqlParameter("p_Ngay_Ct1", pd_Ngay_Ct1), new SqlParameter("p_Ngay_Ct2", pd_Ngay_Ct2), new SqlParameter("p_Ma_Kho", ps_Ma_Kho), new SqlParameter("p_Ma_Vt", ps_Ma_Vt) };
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "Tinh_Gia_NTXT";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                command.Parameters.AddRange(values);
                command.ExecuteNonQuery();
                AppDataAccess.CloseConnection(eZConnection);
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
        }

    }
}

